package com.sample.consumer;

import java.util.concurrent.CompletableFuture;

import org.springframework.stereotype.Service;

import com.sample.entity.OrderDTO;
import com.sample.service.OrderServiceAsync;
import com.swak.annotation.FluxReference;
import com.swak.annotation.rabbit.RabbitSubscriber;
import com.swak.rabbit.message.Message;

/**
 * 订单消费
 * 
 * @author 618lf
 */
@Service
public class OrderConsumer {

	@FluxReference
	private OrderServiceAsync orderService;

	@RabbitSubscriber(queue = "Order_queue")
	public CompletableFuture<Void> order(Message message) {
		OrderDTO order = message.payload2Object();
		return this.orderService.book(order);
	}
}